package argo.hot100.search2mid;

public class SearchMatrix {
    public boolean searchMatrix(int[][] matrix, int target) {
        int x = 0, y = matrix[0].length - 1;

        while (x >= 0 && x < matrix.length && y >= 0 && y < matrix[0].length) {
            if (matrix[x][y] > target) {
                y--;
            } else if (matrix[x][y] < target) {
                x++;
            } else {
                return true;
            }
        }
        return false;


    }
}
